<?php

namespace App\Third;

use GuzzleHttp;

class Juhe
{
    public static function getFreeBelongs($mobile)
    {
        $url = "https://cx.shouji.360.cn/phonearea.php?";
        $params = array(
            "number" => $mobile,//需要查询的手机号码
        );
        $http = new GuzzleHttp\Client();

        $response = $http->request('GET', $url, [
            'query' => $params
        ]);
        $result = json_decode($response->getBody()->getContents(), true);
        if ($result) {
            if ($result['code'] == 0) {
                return $result;
            } else {
                return [];
            }
        } else {
            return [];
        }
    }


    public static function getBelongs($mobile)
    {
        $url = "http://apis.juhe.cn/mobile/get";
        $params = array(
            "phone" => $mobile,//需要查询的手机号码
            "key" => "b79d93632e8ce1d63d19289746258cd8",//应用APPKEY(应用详细页查询)
        );
        $http = new GuzzleHttp\Client();

        $response = $http->request('GET', $url, [
            'query' => $params
        ]);
        $result = json_decode($response->getBody()->getContents(), true);
        if ($result) {
            if ($result['error_code'] == 0) {
                return $result;
            } else {
                return [];
            }
        } else {
            return [];
        }
    }
}
